<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>嘉童游乐中心-节假日管理</title>
<jsp:include page="/common/commonCss.jsp" />
<jsp:include page="/common/commonJs.jsp" />
<script language="javascript" src="${basePath }commonJs/tags/My97DatePicker/WdatePicker.js"></script>
<title>节假日管理</title>
<script type="text/javascript">
	var hldId = ''; var nYear = '';
	var sDate = '';var eDate = '';
	var sTemp = '';var eTemp = '';
	$(document).ready(function(){
		
		initTab("holidayForm");
	});
	
	function initTab(formId){
		var year = $("#year").val();
		$("#hiddenYear").val(year);
		var form = $("#" + formId);
		var pagebean = new PageBean(form);
		pagebean.setTableId("holidayTable");
		pagebean.setCallback(initTable);
		pagebean.setFootId("pagefoot");
		setPagebeanObj(pagebean);
		pagebean.doPage();
	}
	
	function initTable(data){
		if(data==null){
			return;
		}
		$.each(data,function(ind,obj){
			var i = ind+1;
			var htm ="<tr>";
			var pkHldId = obj.pkHldId;
			var startDate = obj.startDate;
			var endDate = obj.endDate;
			
			startDate = getSmpFormatDate(new Date(startDate),
					false);
			endDate = getSmpFormatDate(new Date(endDate), false);
			 htm +="<td>" + obj.year +"</td>";
			 htm +="<td>" + obj.hldName + "</td>";
			 htm +="<td>" + obj.hldAbbr + "</td>";
			 htm +="<td>" + startDate + "</td>";
			 htm +="<td>" + endDate + "</td>";
			 htm +="<td>" + "<input type='button' value='编辑' class='btn_l' onclick=\"opene('"+pkHldId+"','"+obj.year+"','"+obj.hldName+"','"+obj.hldAbbr+"','"+startDate+"','"+endDate+"')\"><input type='button' value='删除' class='btn_l ml10' onclick=\"deleteHld('"+pkHldId+"')\"></td>" + "</td></tr>";
			 $("#holidayTable").find("tr:eq("+ind+")").after(htm);
		});
		
	}
	
	function selectHoliday(formId) {
		$("#" + formId + " input:hidden[name='pageNo']").val(1);
		initTab(formId);
	}
	
	function addHld(){
		var year = $("#year1").val();
		var hldName = $("#hldName").val();
		var holidayName = encodeURI(hldName);
		var hldAbbr = $("#hldAbbr").val();
		var holidayAbbr = encodeURI(hldAbbr);
		var startDate = $("#startDate").val();
		var endDate = $("#endDate").val();
		if(hldName==null||startDate==null||endDate==null||endDate.length==0||startDate.length==0||hldName.length==0){
			alertInfo("带*的为必填项");
			return;
		}
		$.ajax({
			url : '${basePath}holiday/addHld.shtml',
			data : {"year":year,"hldName":holidayName,"hldAbbr":holidayAbbr,"startDate":startDate,"endDate":endDate},
			dataType : "text",
			async : false,
			success : function(result) {
				if(result=="success"){
				alertInfo("添加成功");
				initTab("holidayForm");
				clean();
				}
			},
			error : function(XMLHttpRequest) {
				 ajaxError(XMLHttpRequest);
				}
		});
	}
	
	function opene(pkHldId,year,hldName,hldAbbr,startDate,endDate){
		hldId = pkHldId;
		nYear = year;
		 sTemp = startDate.split("-");
		sDate = sTemp[0]+'/'+sTemp[1]+'/'+sTemp[2];
		 eTemp = endDate.split("-");
		 eDate = eTemp[0]+'/'+eTemp[1]+'/'+eTemp[2];
		$("#year2 option:[value="+nYear+"]").attr("selected",true);
		$("#hldName1").val(hldName);
		$("#hldAbbr1").val(hldAbbr);
		$("#startDate1").val(sDate);
		$("#endDate1").val(eDate);
		refreshSelect();
		$('#e').window('open');
		
	}
	
	function update(){
		var year = $("#year2").val();
		var hldName = $("#hldName1").val();
		var holidayName = encodeURI(hldName);
		var hldAbbr = $("#hldAbbr1").val();
		var holidayAbbr = encodeURI(hldAbbr);
		var startDate = $("#startDate1").val();
		var endDate = $("#endDate1").val();
		if(hldName==null||startDate==null||endDate==null||endDate.length==0||startDate.length==0||hldName.length==0){
			alertInfo("带*的为必填项");
			return;
		}
		$.ajax({
			url : '${basePath}holiday/updateByPrimaryKey.shtml',
			data : {"pkHldId":hldId,"year":year,"hldName":holidayName,"hldAbbr":holidayAbbr,"startDate":startDate,"endDate":endDate},
			dataType : "text",
			type:"post",
			async : false,
			success : function(result) {
				if(result=="success"){
				alertInfo("修改成功");
				initTab("holidayForm");
				clean();
				}
			},
			error : function(XMLHttpRequest) {
				 ajaxError(XMLHttpRequest);
				}
		});
	}
	
	function clean(){
		$("#hldName").val('');
		$("#hldAbbr").val('');
		$("#startDate").val('');
		$("#endDate").val('');
		$('#ex').window('close');
		$('#e').window('close');
	}
	
	function deleteHld(pkHldId){
		$.messager.confirm('警告', $common_confirm_delete, function(r) {
			if (r) {
		$.ajax({
			url : '${basePath}holiday/delete.shtml',
			data : {"pkHldId":pkHldId},
			dataType : "text",
			async : false,
			success : function(result) {
				if(result=="success"){
				alertInfo("删除成功");
				initTab("holidayForm");
				}
			},
			error : function(XMLHttpRequest) {
				 ajaxError(XMLHttpRequest);
				}
		});}
		});
	}
	
</script>
</head>
<body class="bg">
<div class="content m_auto">
	<div class="content_l mt10">
    	<ul>
            	<shiro:hasPermission name="authority/role/home.shtml">
         <li  ><a href="${basePath}authority/role/home.shtml"><i class="nav_icon_u"></i><br>角色管理</a></li>
           </shiro:hasPermission>
           <shiro:hasPermission name="authority/user/home.shtml">
            <li><a href="${basePath}authority/user/home.shtml"><i class="nav_icon_t"></i><br>用户管理</a></li>
           </shiro:hasPermission>
           <shiro:hasPermission name="SalesRelation/mem.shtml">
            <li><a href="${basePath}SalesRelation/mem.shtml"><i class="nav_icon_s"></i><br>销售关联会员</a></li>
          </shiro:hasPermission>
            <shiro:hasPermission name="ParRoomDetail/ParRoom.shtml">
            <li><a href="${basePath}ParRoomDetail/ParRoom.shtml"><i class="nav_icon_r"></i><br>房间管理</a></li>
           </shiro:hasPermission>
           <shiro:hasPermission name="SysBarCode/system.shtml">
            <li><a href="${basePath }SysBarCode/system.shtml"><i class="nav_icon_q"></i><br>条码维护</a></li>
            </shiro:hasPermission>
            <shiro:hasPermission name="WfmAuthorize/toShenP.shtml">
            <li><a href="${basePath}WfmAuthorize/toShenP.shtml"><i class="nav_icon_s"></i><br>审批转授权</a></li>
            </shiro:hasPermission>
            <shiro:hasPermission name="holiday/sysHoliday.shtml">
            <li  class="content_hover"><a href="${basePath}holiday/sysHoliday.shtml"><i class="nav_icon_q"></i><br>节假日管理</a></li>
            </shiro:hasPermission>
        </ul>
    </div>
    <form action="${basePath}holiday/findHoliday.shtml" method="post" id="holidayForm">
					<input type="hidden" name="pageNo" value="1"> 
					<input type="hidden" name="pageSize" value="10">
					<input type="hidden" name="year" id="hiddenYear">
				</form>
    <div class="content_r mt10">
    	<!---- 内容 --->
        <div class="p20">
        <div class="file_single_dl_i ">
        	<dl>
            	<dd><label>年份：</label>
                	<div class="uboxstyle">
                        <select name="year" id="year" onchange="selectHoliday('holidayForm')">
                         <option value=''>全部</option>
                            <option value='2014'>2014</option><option value='2015'>2015</option>
                            <option value='2016'>2016</option><option value='2017'>2017</option>
                            <option value='2018'>2018</option>
                            <option value='2020'>2020</option><option value='2021'>2021</option>
                           <option value='2022'>2022</option><option value='2023'>2023</option>
                           <option value='2024'>2024</option><option value='2025'>2025</option>
                           <option value='2026'>2026</option><option value='2027'>2027</option>
                           <option value='2028'>2028</option><option value='2029'>2029</option>
                           <option value='2030'>2030</option><option value='2031'>2031</option>
                           <option value='2032'>2032</option><option value='2033'>2033</option>
                           <option value='2034'>2031</option><option value='2034'>2034</option>
                        </select>
                    </div>
                </dd>
                <dd><input type="button" class="btn ml10" value="新增" onclick="$('#ex').window('open')"></dd>
            </dl>
        </div>
        <table class="table" id="holidayTable">
        	<tr>
            	<th>年份</th>
                <th>节假日名称</th>
                <th>缩略语</th>
                <th>假日开始日期</th>
                <th>假日结束日期</th>
                <th>操作</th>
            </tr>
        </table>
        <!----翻页----->
        
        <div class="page fr m10" id="pagefoot" >
        </div>
        <!----翻页----->
        </div>
        <!---- 内容 --->
    </div>
</div>




<!---弹出层--->
<div id="ex" class="easyui-window" title="节假日配置" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:600px; height:320px; position:relative;">

	<div class="ul_label_x">
    	<ul>
        	<li>
            	<label>年份：</label>
                <div class="uboxstyle">
                    <select name="year1" id="year1">
                         <option value='2014'>2014</option><option value='2015'>2015</option>
                            <option value='2016'>2016</option><option value='2017'>2017</option><option value='2018'>2018</option>
                            <option value='2020'>2020</option><option value='2021'>2021</option>
                           <option value='2022'>2022</option><option value='2023'>2023</option>
                           <option value='2024'>2024</option><option value='2025'>2025</option>
                           <option value='2026'>2026</option><option value='2027'>2027</option>
                           <option value='2028'>2028</option><option value='2029'>2029</option>
                           <option value='2030'>2030</option><option value='2031'>2031</option>
                           <option value='2032'>2032</option><option value='2033'>2033</option>
                           <option value='2034'>2031</option><option value='2034'>2034</option>
                    </select>
                </div>
            </li>
            <li><label>节假名称：</label><input type="text" class="iput_t w200" id="hldName">&nbsp;<span style="color: red; font-size:large;" >*</span></li>
            <li><label>缩略语：</label><input type="text" class="iput_t w200" id="hldAbbr"></li>
            <li><label>开始日期：</label><input type="text" id="startDate" onclick="WdatePicker({dateFmt:'yyyy/MM/dd',isShowWeek:true,isShowClear:true,readOnly:true})" class="Wdate iput_t w200">&nbsp;<span style="color: red; font-size:large;" >*</span></li>
            <li><label>结束日期：</label><input type="text" id="endDate" onclick="WdatePicker({dateFmt:'yyyy/MM/dd',isShowWeek:true,isShowClear:true,readOnly:true})" class="Wdate iput_t w200">&nbsp;<span style="color: red; font-size:large;" >*</span></li>
        	
        </ul>
    </div>

    <div class="btm_btn btm_bg">
    	<dl>
        	<dd><input type="button" class="btn" onclick="addHld()" value="确定"></dd>
            <dd><input type="button" class="btn" onclick="clean()" value="取消"></dd>
        </dl>
    </div>
</div>
<!---弹出层--->













<!---弹出层--->
<div id="e" class="easyui-window" title="节假日配置" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:600px; height:320px; position:relative;">

	<div class="ul_label_x">
    	<ul>
        	<li>
            	<label>年份：</label>
                <div class="uboxstyle">
                    <select name="year2" id="year2">
                        <option value='2014'>2014</option><option value='2015'>2015</option>
                            <option value='2016'>2016</option><option value='2017'>2017</option><option value='2018'>2018</option>
                            <option value='2020'>2020</option><option value='2021'>2021</option>
                           <option value='2022'>2022</option><option value='2023'>2023</option>
                           <option value='2024'>2024</option><option value='2025'>2025</option>
                           <option value='2026'>2026</option><option value='2027'>2027</option>
                           <option value='2028'>2028</option><option value='2029'>2029</option>
                           <option value='2030'>2030</option><option value='2031'>2031</option>
                           <option value='2032'>2032</option><option value='2033'>2033</option>
                           <option value='2034'>2031</option><option value='2034'>2034</option>
                    </select>
                </div>
            </li>
            <li><label>节假名称：</label><input type="text" class="iput_t w200" id="hldName1">&nbsp;<span style="color: red; font-size:large;" >*</span></li>
            <li><label>缩略语：</label><input type="text" class="iput_t w200" id="hldAbbr1"></li>
            <li><label>开始日期：</label><input type="text" id="startDate1" onclick="WdatePicker({dateFmt:'yyyy/MM/dd',isShowWeek:true,isShowClear:true,readOnly:true})" class="Wdate iput_t w200">&nbsp;<span style="color: red; font-size:large;" >*</span></li>
            <li><label>结束日期：</label><input type="text" id="endDate1" onclick="WdatePicker({dateFmt:'yyyy/MM/dd',isShowWeek:true,isShowClear:true,readOnly:true})" class="Wdate iput_t w200">&nbsp;<span style="color: red; font-size:large;" >*</span></li>
        	
        </ul>
    </div>

    <div class="btm_btn btm_bg">
    	<dl>
        	<dd><input type="button" class="btn" onclick="update()" value="确定"></dd>
            <dd><input type="button" class="btn" onclick="clean()" value="取消"></dd>
        </dl>
    </div>
</div>
<!---弹出层--->





